package com.googlecode.stockhamster.utils;

import java.net.MalformedURLException;

import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;

public class XFireStub<T> {
	private T stub;

	@SuppressWarnings("unchecked")
	public XFireStub(String url, Class<?> c) throws MalformedURLException {
		Service bankModel = new ObjectServiceFactory().create(c);
		XFireProxyFactory factory = new XFireProxyFactory(XFireFactory
				.newInstance().getXFire());
		stub = (T)factory.create(bankModel, url);
	}
	
	public T getStub() {
		return stub;
	}
}
